class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        sort(magazine.begin(), magazine.end());
        sort(ransomNote.begin(), ransomNote.end());
        int idx = 0;
        for (auto x : magazine) {
            if (x == ransomNote[idx]) {
                idx++;
            }
        }
        return idx == ransomNote.size();
    }
};